package cn.xpf.study.utils;

import cn.xpf.study.model.Lesson;
import cn.xpf.study.model.vo.LessonVo;
import java.util.HashMap;
import java.util.Map;

/**
 * Create on 2021/5/15
 *
 * @author shuxinsheng@qiyi.com
 **/
public class PreviewUtil {

    private static final Map<Long, LessonVo> cacheMap = new HashMap<>();

    public static Long addLessonVo(LessonVo lessonVo) {
        if (lessonVo == null) {
            return null;
        }
        long hash = lessonVo.hashCode();
        if (cacheMap.size() > 100) {
            cacheMap.clear();
        }
        cacheMap.put(hash, lessonVo);
        return hash;
    }

    public static LessonVo getLessonVo(long hashCode) {
        return cacheMap.get(hashCode);
    }

}
